<!DOCTYPE html>
<html>

<head>
  <meta charset='utf-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <title>Page Title</title>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
</head>


<body>
  <input type="text" id="input">
</body>

</html>>
<script>
  function f(e) {
    console.log(Date.now(), e.target.value)
  }
  // function youFunc(func, t) {
  //   var time = 0
  //   return function(e){
  //     if(Date.now()-time>=t){
  //       func(e)
  //       time=Date.now()
  //     }else {
  //       // console.log('时间没到');
  //     }
  //   }
  // }
//   function tr (fn,s) {
//     let now = Date.now()
//     return function (e){
//         if( Date.now() - now >s ){
//              fn(e)
//              now = Date.now()
//        }else {
//               //  console.log('不执行')
//        }
//     }
// }
//   var f1 = tr(f, 1000);
//   console.log(f1)
//   document.getElementById("input").addEventListener("input", function (e) {
//     f1(e)
//   })
async function async1() {
    console.log('async1 start');
    await async2();
    console.log('async1 end');
}
async function async2() {
    console.log('async2');
}

console.log('script start');//1

setTimeout(function() {
    console.log('setTimeout');
}, 0)

async1();//script start   - >  async1 start - >  async2    - > promise1 - > script end - > async1 end - >   promise 2 - >  setTimeout 

new Promise(function(resolve) {
    console.log('promise1');
    resolve();
}).then(function() {
    console.log('promise2');
});
console.log('script end');
// script start
// async1 start
// async2
// async1 end
// setTimeout
</script>
